""" 
Step:
	1. python manage shell
	2. import fake_data
"""

import random
import datetime
from uuid import uuid4


#

from blog.models import db, User, Tag, Post


# INIT  User instance

user = User(id=str(uuid4()), username='frog', password='1234567')
db.session.add(user)
db.session.commit()

# =================================================================================#

# INIT Tag instance list

user = db.session.query(User).first()

tag_one = Tag(id=str(uuid4()), name='Python')
tag_two = Tag(id=str(uuid4()), name='Flask')
tag_three = Tag(id=str(uuid4()), name='SQLAlchemy')
tag_four = Tag(id=str(uuid4()), name='frog')
tag_list = [tag_one, tag_two, tag_three, tag_four]

s = "Example Text"

# INIT Post instance

for i in range(20):
	new_post = Post(id=str(uuid4()), title="Post" + str(i))
	new_post.users = user
	new_post.publish_date = datetime.datetime.now()
	new_post.text = s
	new_post.tags = random.sample(tag_list, random.randint(1, 3))
	db.session.add(new_post)

db.session.commit()